#include "tcp_server.hpp"
#include <iostream>
#include <memory>

using namespace ns_server;
using namespace std;

// 使用手册
static void usage(std::string proc)
{
    std::cout << "Usage:\n\t" << proc << "serverport\n"
              << std::endl;
}

std::string echo(const std::string& message)
{
    return message;
}

//./tcp_server 8888
int main(int args, char* argv[])
{
    if(args != 2)
    {
        usage(argv[0]);
        exit(USAGE_ERR);
    }

    uint16_t port = atoi(argv[1]); //字符串转整数

    unique_ptr<TcpServer> tsvr(new TcpServer(echo, port));

    tsvr->ServerInit();
    tsvr->Start();

    return 0;
}